<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // Promise.resolve('a'); // 将现有的东西转成 成功的状态
        // Promise.reject('b'); // 将现有的东西转成 失败的状态

        Promise.resolve('a').then(res => {
            console.log(res); //  a 
        });

        Promise.reject('b').then(res => {
            console.log('res', res);
        }).catch(err => {
            console.log('err', err); // err b
        });

        // ------------------------------------------------------------

        let p1 = Promise.resolve('aaa-ok');
        p1.then(res => {
            console.log('res', res); // res aaa-ok
        });

        let p2 = Promise.reject('bbb-no');
        p2.then(res => {
            console.log('res', res);
        }).catch(err => {
            console.log('err', err); // err bbb-no
        })
    </script>
</body>

</html>